Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

XListCtrl.h

Go to the documentation of this file.
00001 // XListCtrl.h  Version 1.3
00002 //
00003 // Author:  Hans Dietrich
00004 //          hdietrich2@hotmail.com
00005 //
00006 // This software is released into the public domain.
00007 // You are free to use it in any way you like.
00008 //
00009 // This software is provided "as is" with no expressed
00010 // or implied warranty.  I accept no liability for any
00011 // damage or loss of business that this software may cause.
00012 //
00013 ///////////////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef XLISTCTRL_H
00016 #define XLISTCTRL_H
00017 
00018 #include "XHeaderCtrl.h"
00019 #ifndef DO_NOT_INCLUDE_XCOMBOLIST
00020 #include "XComboList.h"
00021 #endif
00022 
00023 extern UINT NEAR WM_XLISTCTRL_COMBO_SELECTION;
00024 extern UINT NEAR WM_XLISTCTRL_CHECKBOX_CLICKED;
00025 
00026 ///////////////////////////////////////////////////////////////////////////////
00027 // Style bits for use with SetExtendedStyleX()
00028 
00029 // none defined yet
00030 
00031 ///////////////////////////////////////////////////////////////////////////////
00032 // CXListCtrl data
00033 
00034 struct XLISTCTRLDATA
00035 {
00036     // ctor
00037     XLISTCTRLDATA()
00038     {
00039         bEnabled             = TRUE;
00040         crText               = ::GetSysColor(COLOR_WINDOWTEXT);
00041         crBackground         = ::GetSysColor(COLOR_WINDOW);
00042         bShowProgress        = FALSE;
00043         nProgressPercent     = 0;
00044         strProgressMessage   = _T("");
00045         bShowProgressMessage = TRUE;
00046         nCheckedState        = -1;
00047         bBold                = FALSE;
00048         nImage               = -1;
00049 #ifndef NO_XLISTCTRL_TOOL_TIPS
00050         strToolTip           = _T("");
00051 #endif
00052         bCombo               = FALSE;
00053         bComboIsClicked      = FALSE;
00054         nComboListHeight     = 10;
00055         nInitialComboSel     = 0;
00056         psa                  = NULL;
00057         dwItemData           = 0;
00058     }
00059 
00060     BOOL            bEnabled;               // TRUE = enabled, FALSE = disabled (gray text)
00061     BOOL            bBold;                  // TRUE = display bold text
00062     int             nImage;                 // index in image list, else -1
00063 #ifndef NO_XLISTCTRL_TOOL_TIPS
00064     CString         strToolTip;             // tool tip text for cell
00065 #endif
00066 
00067     // for combo
00068     BOOL            bCombo;                 // TRUE = display combobox
00069     BOOL            bComboIsClicked;        // TRUE = downarrow is clicked
00070     CStringArray *  psa;                    // pointer to string array for combo listbox
00071     int             nComboListHeight;       // combo listbox height (in rows)
00072     int             nInitialComboSel;       // initial combo listbox selection (0 = first)
00073 
00074     // for color
00075     COLORREF    crText;
00076     COLORREF    crBackground;
00077 
00078     // for progress
00079     BOOL        bShowProgress;              // true = show progress control
00080     int         nProgressPercent;           // 0 - 100
00081     CString     strProgressMessage;         // custom message for progress indicator -
00082                                             // MUST INCLUDE %d
00083     BOOL        bShowProgressMessage;       // TRUE = display % message, or custom message
00084                                             // if one is supplied
00085     // for checkbox
00086     int         nCheckedState;              // -1 = don't show, 0 = unchecked, 1 = checked
00087 
00088     DWORD       dwItemData;                 // pointer to app's data
00089 };
00090 
00091 
00092 ///////////////////////////////////////////////////////////////////////////////
00093 // CXListCtrl class
00094 
00095 class CXListCtrl : public CListCtrl
00096 {
00097 // Construction
00098 public:
00099     CXListCtrl();
00100     virtual ~CXListCtrl();
00101 
00102 // Attributes
00103 public:
00104 
00105 // Operations
00106 public:
00107     int     CountCheckedItems(int nSubItem);
00108     BOOL    DeleteAllItems();
00109     BOOL    DeleteItem(int nItem);
00110     void    DeleteProgress(int nItem, int nSubItem);
00111     BOOL    GetBold(int nItem, int nSubItem);
00112     int     GetCheckbox(int nItem, int nSubItem);
00113     int     GetColumns();
00114     CString GetComboText(int iItem, int iSubItem);
00115     int     GetCurSel();
00116     BOOL    GetEnabled(int nItem);
00117     DWORD   GetExtendedStyleX() { return m_dwExtendedStyleX; }
00118     int     GetHeaderCheckedState(int nSubItem);
00119     DWORD   GetItemData(int nItem);
00120     BOOL    GetSubItemRect(int iItem, int iSubItem, int nArea, CRect& rect);
00121     int     InsertItem(int nItem, LPCTSTR lpszItem);
00122     int     InsertItem(int nItem, 
00123                        LPCTSTR lpszItem, 
00124                        COLORREF crText, 
00125                        COLORREF crBackground);
00126     int     InsertItem(const LVITEM* pItem);
00127     BOOL    SetBold(int nItem, int nSubItem, BOOL bBold);
00128     BOOL    SetComboBox(int nItem, 
00129                         int nSubItem, 
00130                         BOOL bEnableCombo, 
00131                         CStringArray *psa,
00132                         int nComboListHeight,
00133                         int nInitialComboSel);
00134     BOOL    SetCheckbox(int nItem, int nSubItem, int nCheckedState);
00135     BOOL    SetCurSel(int nItem);
00136     BOOL    SetEnabled(int nItem, BOOL bEnable);
00137     DWORD   SetExtendedStyleX(DWORD dwNewStyle) 
00138     {
00139         DWORD dwOldStyle = m_dwExtendedStyleX;
00140         m_dwExtendedStyleX = dwNewStyle;
00141         return dwOldStyle;
00142     }
00143 
00144     BOOL    SetHeaderCheckedState(int nSubItem, int nCheckedState);
00145     int     SetItem(const LVITEM* pItem);
00146     BOOL    SetItemData(int nItem, DWORD dwData);
00147     BOOL    SetItemImage(int nItem, int nSubItem, int nImage);
00148     BOOL    SetItemText(int nItem, int nSubItem, LPCTSTR lpszText); 
00149     BOOL    SetItemText(int nItem, 
00150                         int nSubItem, 
00151                         LPCTSTR lpszText,
00152                         COLORREF crText, 
00153                         COLORREF crBackground);
00154     BOOL    SetProgress(int nItem, 
00155                         int nSubItem, 
00156                         BOOL bShowProgressText = TRUE, 
00157                         LPCTSTR lpszProgressText = NULL);
00158     void    UpdateProgress(int nItem, int nSubItem, int nPercent);
00159     void    UpdateSubItem(int nItem, int nSubItem);
00160 
00161 #ifndef NO_XLISTCTRL_TOOL_TIPS
00162     void DeleteAllToolTips();
00163     BOOL SetItemToolTipText(int nItem, int nSubItem, LPCTSTR lpszToolTipText);
00164     CString GetItemToolTipText(int nItem, int nSubItem);
00165     virtual int OnToolHitTest(CPoint point, TOOLINFO * pTI) const;
00166 #endif
00167 
00168 // Overrides
00169     // ClassWizard generated virtual function overrides
00170     //{{AFX_VIRTUAL(CXListCtrl)
00171 public:
00172     virtual void PreSubclassWindow();
00173     //}}AFX_VIRTUAL
00174 
00175 // Implementation
00176 public:
00177     CXHeaderCtrl    m_HeaderCtrl;
00178     CImageList      m_cImageList;   // Image list for the header control
00179 
00180 protected:
00181     void DrawCheckbox(int nItem, 
00182                       int nSubItem, 
00183                       CDC *pDC, 
00184                       COLORREF crText,
00185                       COLORREF crBkgnd,
00186                       CRect& rect, 
00187                       XLISTCTRLDATA *pCLD);
00188 #ifndef DO_NOT_INCLUDE_XCOMBOLIST
00189     void DrawComboBox(int nItem, 
00190                       int nSubItem, 
00191                       CDC *pDC, 
00192                       COLORREF crText,
00193                       COLORREF crBkgnd,
00194                       CRect& rect, 
00195                       XLISTCTRLDATA *pCLD);
00196     void UnpressComboButton();
00197 #endif
00198     int DrawImage(int nItem, 
00199                   int nSubItem, 
00200                   CDC* pDC, 
00201                   COLORREF crText,
00202                   COLORREF crBkgnd,
00203                   CRect rect,
00204                   XLISTCTRLDATA *pXLCD);
00205     void DrawProgress(int nItem, 
00206                       int nSubItem, 
00207                       CDC *pDC, 
00208                       COLORREF crText,
00209                       COLORREF crBkgnd,
00210                       CRect& rect, 
00211                       XLISTCTRLDATA *pCLD);
00212     void DrawText(int nItem, 
00213                   int nSubItem, 
00214                   CDC *pDC, 
00215                   COLORREF crText,
00216                   COLORREF crBkgnd,
00217                   CRect& rect, 
00218                   XLISTCTRLDATA *pCLD);
00219     void GetDrawColors(int nItem,
00220                        int nSubItem,
00221                        COLORREF& colorText,
00222                        COLORREF& colorBkgnd);
00223     void SubclassHeaderControl();
00224 
00225     BOOL            m_bHeaderIsSubclassed;
00226     DWORD           m_dwExtendedStyleX;
00227 
00228     COLORREF        m_cr3DFace;
00229     COLORREF        m_cr3DHighLight;
00230     COLORREF        m_cr3DShadow;
00231     COLORREF        m_crBtnFace;
00232     COLORREF        m_crBtnShadow;
00233     COLORREF        m_crBtnText;
00234     COLORREF        m_crGrayText;
00235     COLORREF        m_crHighLight;
00236     COLORREF        m_crHighLightText;
00237     COLORREF        m_crWindow;
00238     COLORREF        m_crWindowText;
00239 
00240 #ifndef DO_NOT_INCLUDE_XCOMBOLIST
00241     BOOL            m_bComboIsClicked;
00242     int             m_nComboItem;
00243     int             m_nComboSubItem;
00244     CRect           m_rectComboButton;
00245     CRect           m_rectComboList;
00246     CXComboList *   m_pListBox;
00247     CFont           m_ListboxFont;
00248     BOOL            m_bFontIsCreated;
00249     CString         m_strInitialComboString;
00250 #endif
00251 
00252 
00253     // Generated message map functions
00254 protected:
00255     //{{AFX_MSG(CXListCtrl)
00256     afx_msg BOOL OnClick(NMHDR* pNMHDR, LRESULT* pResult);
00257     afx_msg BOOL OnColumnClick(NMHDR* pNMHDR, LRESULT* pResult);
00258     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
00259     afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
00260     afx_msg void OnDestroy();
00261     afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00262     afx_msg void OnPaint();
00263     afx_msg void OnSysColorChange();
00264     //}}AFX_MSG
00265 #ifndef DO_NOT_INCLUDE_XCOMBOLIST
00266     afx_msg void OnTimer(UINT nIDEvent);
00267     afx_msg LRESULT OnComboEscape(WPARAM, LPARAM);
00268     afx_msg LRESULT OnComboReturn(WPARAM, LPARAM);
00269     afx_msg LRESULT OnComboKeydown(WPARAM, LPARAM);
00270     afx_msg LRESULT OnComboLButtonUp(WPARAM, LPARAM);
00271 #endif
00272 
00273 #ifndef NO_XLISTCTRL_TOOL_TIPS
00274     virtual afx_msg BOOL OnToolTipText(UINT id, NMHDR * pNMHDR, LRESULT * pResult);
00275 #endif
00276 
00277     DECLARE_MESSAGE_MAP()
00278 };
00279 
00280 /////////////////////////////////////////////////////////////////////////////
00281 
00282 //{{AFX_INSERT_LOCATION}}
00283 // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
00284 
00285 #endif //XLISTCTRL_H

Generated on Mon Sep 12 19:58:59 2005 for Destiny3D by doxygen1.3-rc3